import { doGet0, doGet1, doGet2, doGet3, doPost1, doPost2, doPost3 } from '@/api/test'

const state = {
}

const mutations = {
}

const actions = {
  get0({ commit, state }) {
    return new Promise((resolve, reject) => {
      doGet0().then(response => {
        console.log("@/store/test/index.js get0()", response)
        const { data } = response
        //commit('TOGGLE_INFO', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  },

  get1({ commit, state }) {
    return new Promise((resolve, reject) => {
      doGet1().then(response => {
        console.log("@/store/test/index.js get1()", response)
        const { data } = response
        //commit('TOGGLE_INFO', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  },

  get2({ commit, state }, id) {
    return new Promise((resolve, reject) => {
      doGet2(id).then(response => {
        console.log("@/store/test/index.js get2()", response)
        const { data } = response
        // commit('TOGGLE_INFO', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  },

  get3({ commit, state }, obj) {
    return new Promise((resolve, reject) => {
      doGet3(obj).then(response => {
        console.log("@/store/test/index.js get3()", response)
        const { data } = response
        // commit('TOGGLE_INFO', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  },

  post1({ commit, state }) {
    return new Promise((resolve, reject) => {
      doPost1().then(response => {
        console.log("@/store/test/index.js post1()", response)
        const { data } = response
        //commit('TOGGLE_INFO', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  },

  post2({ commit, state }, id) {
    return new Promise((resolve, reject) => {
      doPost2(id).then(response => {
        console.log("@/store/test/index.js post2()", response)
        const { data } = response
        // commit('TOGGLE_INFO', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  },

  post3({ commit, state }, obj) {
    return new Promise((resolve, reject) => {
      doPost3(obj).then(response => {
        console.log("@/store/test/index.js post3()", response)
        const { data } = response
        // commit('TOGGLE_INFO', data)
        resolve(data)
      }).catch(error => {
        reject(error)
      })
    })
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
